import { Page } from "@/interface/log";
import { R, SysFile } from "@/interface/user";
import request from '../utils/request'
import { AxiosResponse } from "axios";
import { ValueType } from "ant-design-vue/es/input-number/src/utils/MiniDecimal";

export function getFilePageApi(current: number, pageSize: number, fileName = '', fileType = '', fileSize: ValueType = -1): Promise<AxiosResponse<R<Page<SysFile[]>>>> {
  return request.get(`/sys/file/manage/all?current=${current}&pageSize=${pageSize}&fileName=${fileName}&fileType=${fileType}&fileSize=${fileSize}`, {
    headers: {
      isToken: true
    }
  });
}

export function addFileApi(file: object): Promise<AxiosResponse<R<any>>> {
  return request.post(`/sys/file/manage/add`, { file }, {
    headers: {
      isToken: true
    }
  });
}

export function deleteFilesApi(ids: string): Promise<AxiosResponse<R<any>>> {
  return request.post(`/sys/file/manage/delete/${ids}`, null, {
    headers: {
      isToken: true
    }
  });
}

export function updateFileApi(params: SysFile): Promise<AxiosResponse<R<any>>> {
  return request.post(`/sys/file/manage/update`, params, {
    headers: {
      isToken: true
    }
  });
}